home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
print
/
lptx600.zip
/
LPTX.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-03-18
|
47KB
|
1,661 lines
title LPTx : Line PrinTer Output Capture Routine
page 60,132
;------------------------------------------------------------
;
; MAIN PROGRAM Version 6.00
;
; (C) Copyright 1987 by Mark DiVecchio, All Rights Reserved
;
.xlist
;
;This program is released for use in non-commercial environments. I
;ask commercial users to register the program with a $25 copyright fee for
;each site (any number of users and computers) at which the program is used.
;
; DISCLAMER : this program tries to perform a function which is
; not supported by DOS. It will work sometime and will not work
; other times. That kind of explains why you don't see this type
; of program on the market.
; I have tested it under DOS 2.1 and DOS 3.1. Some users have
; reported trouble when running under DOS 3.x and for other users
; it works fine. USE AT YOUR OWN RISK.
;
; Mark C. DiVecchio
; 10435 Mountain Glen Terrace
; San Diego, CA 92131
; 619-566-6810
;------------------------------------------------------------
; Updates for Version 6.00 18 Mar 87
;
; Added use of Timer Interrupt and Idle interrupt to permit
; writing to disk
;
; Added a switch to inhibit the output of linefeed characters when
; capturing a file. Program strips linefeed character at the
; end of the line if you turn on this switch. The switch is -l on the
; command line when you open a capture file.
;
; This version does not use the PSP swapping of previous versions.
;
;------------------------------------------------------------
; Updates for Version 5.02 19 Nov 86
;
; Added -i inactivate option. Must be only option on command line :
; lptx -i
;
; This version adds a check for DOS interuupt 21h
; function 40h for standard printer device = 0004.
;
; This addition was suggested by Dale Letterman of Seattle.
;
; Assembled using MicroSoft MASM v 4.0
;
; Program is called and used in the same way as version 3.00
;
; I now enter DOS with interrupts disabled.
;
; Added a switch to inhibit the checking of the Critical Section Flag
; Add -x to the command line the first time that you run LPTx.
;
;------------------------------------------------------------
; Updates for Version 5.00 13 May 86
;
; This version also takes over the DOS interuupt 21h and specifically
; checks for function 5.
; If that is the call, LPTx captures the character if LPTx has been
; activated. If it is a DOS call, LPTx assumes that DOS wants LPT1 since
; there is no way for the DOS call to specify a line printer number.
;
; Uses undocumented DOS int 21h calls 50h and 51h.
; 50h Set new current Program Segment Prefix(PSP) from
; segment number in BX
; 51h Get current PSP into BX.
; These calls are used before any file is opened by the resident portion
; of LPTx. There is some concern that DOS puts information about open files
; into the current PSP. Before we open our spooler file, we want to set
; the current PSP to our PSP and then restore it after the file I/O
; is complete. This idea was expressed in PC Magazine May 13, 1986 on page
; 314 in an article by Charles Petzold.
;
;
; This version 5.0 does not obsolete versions 4.0 and 3.0. Those versions
; may work under some conditions where this one does not and vica versa.
;------------------------------------------------------------
; Updates for Version 4.01 5 May 86
;
; Had an error in the way LPTx detected if it was already in memory.
; This error existed from back in version 3.00 and may have been
; the cause of this program locking up the system the very first
; time it was called.
;------------------------------------------------------------
; Updates for Version 4.0 25 April 86
;
; Assembled using MicroSoft MASM v 4.0
;
; Program is called and used in the same way as version 3.00
;
; Modified the code to check if DOS was running when the print interrupt
; occurs. If so the print request is routed back to the regular line
; printer. This will limit the use of this capture program to user
; programs which do their own output without going to DOS.
;
; In turn, this guarantees that we do re-enter DOS.
;
; The trick of saving the DOS stack was dropped in this version and
; I have resorted to another trick which I garnered from the
; following message found on info-ibmpc. I use method number 2.
;
; This version 4.0 does not obsolete version 3.0. That version may
; work under some conditions where this one does not and vica versa.
; This one worked fine for me using DOS 2.1 and 123 version 1.A.
; Will not work with Shift PrtSc.
;
comment *
Date: Thu, 30 Jan 86 08:47:51 est
Subject: File I/O from resident programs
To: allegra!seismo!usc-isib.arpa!info-ibmpc
Regarding opening up a file when you are terminate-and-stay-resident:
Be very careful when you attempt this. Many an FAT has been eaten for
lunch when I first tried doing it. Two ways that work like a charm:
1) Take over interrupt 0x28. This interrupt gets called by DOS
while its waiting for a key to be hit. Whenever it does get
called (your program should not be time critical, btw, as
this routine is never called from CPU intensive tasks), it
is safe to do with DOS what you will. (Except for certain
interruptions, such as Search First and Search Next, which
either you'll screw-up for the foreground task, or they'll
screw-up for you.)
2) Get the Critical Section Flag by issuing an int 21, with ah=0x34.
This returns a pointer to a flag in ES:BX. When this flag is
NULL, and interrupts are on, it is safe to play DOS games.
Unless you are the last program to take over the interrupt,
don't trust the flag word: many "fine" programs like SideKick
do not give you a true copy of the flag word on the stack, but
rather give a simple "pushf" after interrupts are turned off.
* ;end of comment
;
; More information from a message posted on USENIX:
;
comment *
From sdcsvax!ihnp4!timeinc!greenber Mon Jul 1 05:12:16 1985
Date: 30 Jun 85 17:12:37 CDT (Sun)
-----------------------------------------------------------
INT 21 - Internal - Return CritSectFlag Pointer (MSDOS generic)
REG AH = 34H
On Return:
ES:BX points to DOS "Critical Section Flag"
When byte pointed to is zero, DOS is supposed to be
safe to interrupt. NOT RELIABLE according to Chris
Dunford.
Examination of DOS 2.10 code in this area
indicates that the byte immediately FOLLOWING this
"Critical Section Flag" must be 00 to permit the
PRINT.COM interrupt to be called. This suggests that
checking the WORD pointed to, rather than the BYTE,
might increase reliability of the test greatly.
-----------------------------------------------------------
INT 28 - Internal routine for MSDOS
This interrupt is called from inside the "get input
from keyboard" routine in DOS, if and only if it is safe to use
INT 21 to access the disk at that time. It is used primarily by
the PRINT.COM routines, but any number of other routines could
be chained to it by saving the original vector, and calling it
with a FAR call (or just JMPing to it) at the end of the new
routine.
Until PRINT.COM installs its own routine, this
interrupt vector simply points to an IRET opcode.
-----------------------------------------------------------
* ;end of comment
;
;------------------------------------------------------------
; Updates for Version 3.0
;
; This version is fully compatible with IBM's PRINT command and
; hopefully most other print spoolers. I changed the method by which
; LPTx determines if a resident copy of itself is already in memory.
;
;------------------------------------------------------------
; This program intercepts the BIOS interrupt 17, the line printer
; interrupt. It will redirect the output of LPT1, LPT2, or LPT3 to a disk
; file. All three redirects may be active at the same time.
;
;
; Background:
;
; The basic problem with this type of program is that PC-DOS as written
; by Microsoft is not re-entrant. That means that if DOS is in control when
; the print interrupt occurs, you can not call DOS again to do some other
; function. Therefore, LPTx can no